package com.miyake.dsp.otdr.ui;

import com.miyake.dsp.otdr.SpliceDetectorSetting;
import com.miyake.dsp.ui.DspTextField;
import com.miyake.dsp.ui.DspWidget;
import com.miyake.dsp.ui.DspWidget.DspWidgetHandler;

public class SpliceDetectorSettingUI extends DspWidget{

	private SpliceDetectorSetting setting;

	public SpliceDetectorSettingUI(SpliceDetectorSetting setting) {
		this.setting = setting;
		
		createHold();
		createThreshold();
	}
	
	private void createHold() {
		DspTextField text = new DspTextField("Hold");
		text.setValue(String.valueOf(setting.getHold()));
		this.add(text);
		
		text.addHandler(new DspWidgetHandler() {
			@Override
			public void onChange(String value) {
				setting.setHold(Integer.valueOf(value));
				fireChange(value);
			}
		});	
	}
	
	private void createThreshold() {
		DspTextField text = new DspTextField("Threshold");
		text.setValue(String.valueOf(setting.getThreshold()));
		this.add(text);
		
		text.addHandler(new DspWidgetHandler() {
			@Override
			public void onChange(String value) {
				setting.setThreshold(Double.valueOf(value));
				fireChange(value);
			}
		});	
	}
}
